
#define SHM_INI_IMPLEMENTATION 1
#define SHM_QUEUE_IMPLEMENTATION 1
#define SHM_LOG_SERVICE_IMPLEMENTATION 1

#include "shm_log_service.h"
#include <signal.h>

shm_log_service_t service;

static void sighandler(int signum) {
  shm_log_service_stop(&service);
}

int main(int argc, char* argv[]) {
  int rslt = 0;
  const char *log_config = "log_service.ini";
  if (argc > 1) {
    log_config = argv[1];
  } else {
    printf("shm_log_service log.ini\n");
    return -1;
  }

  // char src_name[] = "test.log";
  // char dst_name[1024];
  // _get_file_name(src_name, dst_name, 2);
  // printf("src:%s dst:%s\n", src_name, dst_name);

  rslt = shm_log_service_init(&service, log_config);
  if (rslt != 0) {
    printf("shm_log_service_init error rslt:%d\n", rslt);
    return -1;
  }

  signal(SIGINT, sighandler);
  signal(SIGQUIT, sighandler);
  printf("run\n");
  shm_log_service_run(&service);
  printf("quit\n");
  shm_log_service_deinit(&service);
  return 0;
}
